import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class DynamicProxy {
    public static void main(String[] args) {
        InvocationHandlerImpl<SpeakerImpl> invocationHandler = new InvocationHandlerImpl<>(new SpeakerImpl());
        Speaker proxy = (Speaker) Proxy.newProxyInstance(
                Speaker.class.getClassLoader(),
                new Class<?>[]{Speaker.class},
                invocationHandler);
        proxy.speak();
    }
}
